import java.util.ArrayList;
import java.util.List;

public class Solution179 {
    public String largestNumber(int[] nums) {
        List<String> list=new ArrayList<>();
        for (int num : nums) {
            list.add(String.valueOf(num));
        }
        list.sort((a,b)-> b.concat(a).compareTo(a.concat(b)));
        StringBuilder stringBuilder=new StringBuilder();
        for (String s : list) {
            stringBuilder.append(s);
        }
        while (stringBuilder.length()>1 && stringBuilder.charAt(0)=='0'){
            stringBuilder.deleteCharAt(0);
        }
        return stringBuilder.toString();
    }

    public static void main(String[] args) {
        System.out.println(new Solution179().largestNumber(new int[]{3,30,34,5,9}));
    }
}
